<?php

namespace App\Http\Controllers;

use App\Http\Models\UserAlbum;
use Illuminate\Http\Request;

use App\Http\Requests;

class UserAlbumController extends Controller
{
    //添加用户到相册
    public function addUserToAlbum()
    {
        $user_id = request('user_id');
        $album_id = request('album_id');
        $data = [
            'user_id' => $user_id,
            'album_id' => $album_id
        ];
        //查找相册存在改用户，
        $res = UserAlbum::where($data)->first();
        if($res)
        {
            return api_return(1,'该相册已有该用户',$res);
        }
        $res = UserAlbum::create($data);
        if(!$res)
        {
            return api_return(0,'数据添加失败',[]);
        }

        return api_return(1,'成功添加用户到相册',$res);
    }
}
